using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input.Touch;

namespace ShipkaDefenders.Screens
{
    class Menu : Screen
    {
        public override void Update(TimeSpan gt, TimeSpan elapsed)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) g.Exit();
        }
        public override void Draw(SpriteBatch sb)
        {
            sb.Begin();
            sb.Draw(g.MapTextures[Background], Vector2.Zero, Color.White);
        }
        public override void Gestures(TimeSpan gt, GestureSample gs)
        {
            switch (gs.GestureType)
            {
                case GestureType.Tap:
                    TapButtons(gs.Position);
                    break;
            }
        }
        public virtual void Selection(string s) { }

        protected List<MenuButton> Buttons = new List<MenuButton>();
        protected string Background;

        private void TapButtons(Vector2 p)
        {
            foreach (MenuButton mb in Buttons)
            {
                if (mb.Rect.Intersects(new Rectangle((int)p.X, (int)p.Y, 1, 1)))
                {
                    Selection(mb.Name);
                    break;
                }
            }
        }
    }
    class MenuButton
    {
        public Rectangle Rect { get; set; }
        public string Name { get; set; }
        public MenuButton(string N, int X, int Y, int W, int H)
        {
            this.Rect = new Rectangle(X, Y, W, H);
            this.Name = N;
        }
    }
}
